﻿using System;
using System.Web.Mvc;
using cludg.Domain.Content.Stories;
using cludg.Web.Core.Controllers;
using System.Web.Mvc.Html;

namespace cludg.Web.RenderHelpers
{
	public static class StorySubjectRenderHelper
	{
		public static void StorySubject(this HtmlHelper html, StorySubject item)
		{
			var controller = html.ViewContext.Controller as BaseController;
			if (controller == null)
			{
				throw new ApplicationException("StorySubject helper can be user only with BaseController objects.");
			}

			var itemType = typeof (StorySubject);
			if (item != null)
			{
				itemType = item.GetType();
			}
			var viewName = controller.ViewRegisterContainer.GetView(itemType);

			html.RenderPartial(viewName, item);
		}
	}
}
